﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class SoliderStateAction : NState<SlgEntitySoldier>
{
    public void Enter(SlgEntitySoldier entity, params object[] args)
    {
        string actionName = (string)args[0];
        bool clipLoop = false;
        if (args.Length >= 2)
            clipLoop = (bool)args[1];

        entity.PlayAction(actionName, clipLoop);
        entity.m_strActionName = actionName;
    }

    public void Execute(SlgEntitySoldier entity, params object[] args)
    {

    }

    public void Exit(SlgEntitySoldier entity, params object[] args)
    {

    }

    public bool OnMessage(SlgEntitySoldier entity, MessageBody message)
    {
        if(message.msgId == entity.m_strActionName)
        {
            if (!entity.InLoop)
            {
                entity.m_strActionName = "";
                entity.ChangeState(SlgSoldierState.c_sSoldier_Idle);
            }
        }

        return false;
    }
}
